package com.dongbo.recorder.screenrecord.adapter;

import java.util.ArrayList;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

/**
 * @author GuoZi
 * @date :2020/5/5 13:26
 * @description:
 */
public class MyPageAdapter extends FragmentPagerAdapter {
    private String[] mTitles;
    private ArrayList<Fragment> mFragments = new ArrayList<>();

    public MyPageAdapter(FragmentManager fm,
                         String[] mTitles,
                         ArrayList<Fragment> mFragments) {
        super(fm);
        this.mTitles = mTitles;
        this.mFragments = mFragments;
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
//        return mTitles[position];
        if(mTitles != null && mTitles.length > position){
            return mTitles[position];
        }else{
            return "";
        }
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }
}
